home *** CD-ROM | disk | FTP | other *** search
- /*
- * L-system for square root computation.
- *
- * No graphical output is generated, so use
- * the following command line:
- *
- * graphtal -p -d no sqrt.lsys
- *
- */
-
- lsystem SQRT;
-
-
- table Iteration
- {
- const epsilon = 0.00001;
-
- Sqrt(r) -> Sqrt(5,1,r,0);
-
- Sqrt(Xnew, Xold, r, n)
- : abs(Xnew-Xold)/abs(Xold) >= epsilon
- -> Sqrt(0.5*(Xnew+r/Xnew), Xnew, r, n+1);
- };
-
- table Result
- {
- Sqrt(Xnew, Xold,r,n)->Resultat(Xnew) IterationsUsed(n);
- };
-
- attributes {
- axiom Sqrt(2);
- derivation Iteration(infinity), Result;
- };
-
-